package o;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public abstract class dmh {
    public static long ˎ(ByteBuffer byteBuffer) {
        ˊ(byteBuffer);
        return ˋ(byteBuffer, byteBuffer.position() + 16);
    }

    public static long ॱ(ByteBuffer byteBuffer) {
        ˊ(byteBuffer);
        return ˋ(byteBuffer, byteBuffer.position() + 12);
    }

    public static int ˏ(ByteBuffer byteBuffer) {
        ˊ(byteBuffer);
        return ˎ(byteBuffer, byteBuffer.position() + 10);
    }

    public static dma<ByteBuffer, Long> ˏ(dmm o_dmm) throws IOException {
        if (o_dmm.ॱ() < 22) {
            return null;
        }
        dma<ByteBuffer, Long> ˏ = ˏ(o_dmm, 0);
        return ˏ == null ? ˏ(o_dmm, 65535) : ˏ;
    }

    private static dma<ByteBuffer, Long> ˏ(dmm o_dmm, int i) throws IOException {
        if (i < 0 || i > 65535) {
            throw new IllegalArgumentException("maxCommentSize: " + i);
        }
        long ॱ = o_dmm.ॱ();
        if (ॱ < 22) {
            return null;
        }
        int min = ((int) Math.min((long) i, ॱ - 22)) + 22;
        ॱ -= (long) min;
        ByteBuffer ॱ2 = o_dmm.ॱ(ॱ, min);
        ॱ2.order(ByteOrder.LITTLE_ENDIAN);
        int ʽ = ʽ(ॱ2);
        if (ʽ == -1) {
            return null;
        }
        ॱ2.position(ʽ);
        ByteBuffer slice = ॱ2.slice();
        slice.order(ByteOrder.LITTLE_ENDIAN);
        return dma.ˋ(slice, Long.valueOf(ॱ + ((long) ʽ)));
    }

    private static int ʽ(ByteBuffer byteBuffer) {
        ˊ(byteBuffer);
        int capacity = byteBuffer.capacity();
        if (capacity < 22) {
            return -1;
        }
        int min = Math.min(capacity - 22, 65535);
        int i = capacity - 22;
        int i2 = 0;
        while (i2 <= min) {
            capacity = i - i2;
            if (byteBuffer.getInt(capacity) == 101010256 && ˎ(byteBuffer, capacity + 20) == i2) {
                return capacity;
            }
            i2++;
        }
        return -1;
    }

    static void ˊ(ByteBuffer byteBuffer) {
        if (byteBuffer.order() != ByteOrder.LITTLE_ENDIAN) {
            throw new IllegalArgumentException("ByteBuffer byte order must be little endian");
        }
    }

    public static int ˎ(ByteBuffer byteBuffer, int i) {
        return byteBuffer.getShort(i) & 65535;
    }

    static long ˋ(ByteBuffer byteBuffer, int i) {
        return ((long) byteBuffer.getInt(i)) & 4294967295L;
    }

    public static int ˋ(ByteBuffer byteBuffer) {
        return byteBuffer.getShort() & 65535;
    }

    static long ॱॱ(ByteBuffer byteBuffer) {
        return ((long) byteBuffer.getInt()) & 4294967295L;
    }
}
